//https://www.acwing.com/problem/content/description/1115/
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;

typedef pair<int, int> PII;
#define x first
#define y second

const int N = 22;

int n, m, sx, sy;
char g[N][N];
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
bool st[N][N];

int bfs()
{
    int ret = 1;
    queue<PII> q;
    q.push({sx, sy});
    st[sx][sy] = true;
    while(q.size())
    {
        auto t = q.front();
        q.pop();
        for(int i = 0; i < 4; i++)
        {
            int tx = t.x + dx[i], ty = t.y + dy[i];
            if(tx >= 0 && tx < n && ty >= 0 && ty < m && !st[tx][ty] && g[tx][ty] == '.')
            {
                q.push({tx, ty});
                st[tx][ty] = true;
                ret++;
            }
        }
    }
    return ret;
}

int main()
{
    while(cin >> m >> n, m && n)
	{
	    memset(st, 0, sizeof st);
	    for(int i = 0; i < n; i++)
	        scanf("%s", g[i]);
	    for(int i = 0; i < n; i++)
	        for(int j = 0; j < m; j++)
	            if(g[i][j] == '@')
	                sx = i, sy = j;
	    printf("%d\n", bfs());
	}
	
	return 0;
}